package com.jf.test.mvp.base

import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.ViewModelProvider

/**
 * @Class: BaseView
 * @Description:
 * @author: github.com/jackyflame
 * @Date: 2021/3/10
 */
open class BaseView<P:BasePresenter<IView<P>>> : AppCompatActivity() ,IView<P>{

    private var binding:ViewDataBinding? = null;

    override var presenter: P? = null

    override val lifecycleOwner: LifecycleOwner
        get() = this

    fun bindView(layoutId:Int,clz:Class<P>){
        presenter =  ViewModelProvider(this).get(clz!!)
        binding = DataBindingUtil.setContentView(this, layoutId);
        presenter?.init(this);
        //binding?.setVariable(BR.viewModel,viewModel);
    }


}